<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	
	<script>
		var form=document.forms[0];
		var eles=form.elements;
		form.onsubmit=function(e){
           e.preventDefault();
           //var val=eles['text'].value;
           var file=eles['file'].files[0];
           if(file){
           	 this.submit();
           }
		}
	</script>
</body>
</html>